<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\business\BusinessPigPrice */

$this->title = $model->number;
$this->params['breadcrumbs'][] = ['label' => 'Business Pig Prices', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;


$total = 0;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
            <?= Html::a('返回','javascript:history.back(-1)'); ?>
            <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="business-pig-price-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'number',
                            'person',
                            'pigno',
                            'fgcost',
                            [
                                'attribute' => 'createtime',
                                'value' => function($model){
                                    return date('Y-m-d',$model->createtime);
                                }
                            ]
                        ],
                    ]) ?>

                </div>
            </div>
        </div>
    </section>

    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <table class="table table-striped" id="cost">
                <tr>
                    <th style="width: 10%">分割类型</th>
                    <th style="width: 10%">金额</th>
                    <th style="width: 10%">销售单位</th>
                    <th style="width: 10%">重量</th>
                    <th style="width: 20%">备注</th>
                </tr>

                <?php foreach ($model->detail as $item => $value)  { ?>
                    <?php $total += $value['price'] ?>
                    <tr class="costdata">
                        <input type="hidden" name="id[]" value="<?= $value['id'] ?>">
                        <td>
                            <select type="text" class="form-control" name="type[]" disabled="true">
                                <?php foreach ($type as $key => $row)  { ?>
                                    <option value="<?= $row['name'] ?>" <?php if($value['type'] == $row['name']) { ?> selected <?php } ?>  ><?= $row['name'] ?></option>
                                <?php } ?>
                            </select>
                        </td>
                        <td><input type="number" class="form-control" value="<?= $value['price'] ?>" name="price[]" disabled="true"></td>
                        <td>
                            <select type="text" class="form-control" name="unit[]" disabled="true">
                                <?php foreach ($unit as $key => $row)  { ?>
                                    <option value="<?= $row['name'] ?>" <?php if($value['unit'] == $row['name']) { ?> selected <?php } ?>><?= $row['name'] ?></option>
                                <?php } ?>
                            </select>
                        </td>
                        <td><input type="number" class="form-control" value="<?= $value['weight'] ?>" name="weight[]" disabled="true"></td>
                        <td><input type="text" class="form-control" value="<?= $value['otherdesc'] ?>" name="otherdesc[]" disabled="true"></td>
                    </tr>
                <?php } ?>

                <tr class="costdata" id="zongji">
                    <td><b>总计</b></td>
                    <td><b><?= $total ?></b></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>


        </div>
    </div>


</section>